{% include "../common/header.html" %}
<style>
.login-regions {
    width: 500px;
    margin: 0 auto;
    margin-top: 12%;
    margin-bottom: 15%;
}

.footer {
    bottom: 0;
    position: absolute;
    width: 100%;
    padding: 40px 0px 0px 0px;
}

.alert-danger.checkright {
    width: 94%;
    margin-top: 10px;
    padding: 10px;
}
</style>

<div class="login-regions">
	<div class="panel panel-success">
		<div class="panel-heading">
			<h3 class="panel-title">管理员登录</h3>
		</div>
		<div class="panel-body">
			<div>
				<div class="form-group">
					<label for="username">用户名</label>
					<input type="text" class="form-control" id="username" value="admin" placeholder="用户名" style="width: 440px;">
					<input type="hidden" id="csrf" value="{{csrf}}">
				</div>
				<div class="form-group">
					<label for="password">密码</label>
					<input type="password" class="form-control" id="password" value="123456" placeholder="密码" style="width: 440px;">
				</div>
				<!--
				<div class="form-group code-region" id="captcha">
					<input type="hidden" name="name" value="" id="challenge">
					<input type="hidden" name="name" value="" id="seccode">
					<input type="hidden" name="name" value="" id="validate">
				</div>
				<p id="wait" class="show">正在加载验证码......</p>
				-->
				<button type="submit" class="btn btn-default" id="loginBtn">登录</button>
			</div>
		</div>
	</div>
</div>


{% include "../common/footer.html" %}
<script>
//极验验证码
$(function() {
	$("#loginBtn").on("click",function(){
		if($("#username").val()==""){
			alert("请填写用户名");
			return false;
		}
		if($("#password").val()==""){
			alert("密码");
			return false;
		}
		//验证通过
		var mydata = {
			username: $("#username").val(),
			password: $("#password").val(),
		}
		$.ajax({
			url: '/login/dologin',
			data: mydata,
			type: 'POST',
			success: function(json) {
                console.log(json)
				if (json.status === 1) {
					alert(json.msg);
					window.location.href = "/index";
				} else {
					alert(json.msg);
				}
			}
		})
	});

});
</script>
